package com.thinkingstar.iads.projectcenter.controller;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bstek.urule.runtime.KnowledgeSession;
import com.thinkingstar.iads.datacenter.entity.DcCRHInfo;
import com.thinkingstar.iads.datacenter.entity.DcCarmaintenanceFacility;
import com.thinkingstar.iads.datacenter.entity.DcProjectDesignCell;
import com.thinkingstar.iads.datacenter.entity.DcProjectMentionInformation;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcProjectDesignCell;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcProjectMention;
import com.thinkingstar.iads.datacenter.entity.dao.DcCarmaintenanceFacilityDao;
import com.thinkingstar.iads.projectcenter.entity.dao.DaoPcProjectData;
import com.thinkingstar.iads.projectcenter.entity.dao.DaoPcProjectFile;
import com.thinkingstar.iads.test.urule.controller.RuleTool;

import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.util.StringHelper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.dao.Cnd;
import org.nutz.dao.QueryResult;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.View;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.springframework.ui.Model;
import org.springframework.web.method.support.ModelAndViewContainer;

import com.thinkingstar.iads.common.filter.GlobalsFilter;
import com.thinkingstar.iads.common.filter.UserLoginFilter;
import com.thinkingstar.iads.common.jsonUtils.AjaxResult;
import com.thinkingstar.iads.common.utils.InitSystemProperties;
import com.thinkingstar.iads.common.utils.POIFileUtil;
import com.thinkingstar.iads.datacenter.entity.DcManufacturerEquipmentField;
import com.thinkingstar.iads.projectcenter.entity.PcProjectEquipmentEquip;
import com.thinkingstar.iads.projectcenter.entity.PcProjectEquipmentEquipInfo;
import com.thinkingstar.iads.projectcenter.entity.PcProjectFile;
import com.thinkingstar.iads.projectcenter.entity.PcProjectInfo;
import com.thinkingstar.iads.projectcenter.serviceImpl.PreviewFileServiceImpl;
import com.thinkingstar.iads.projectcenter.serviceImpl.ProjectDesignManagerServiceImpl;


/**
 * 项目中心相关
 * @author Administrator
 *
 */
@IocBean
@At("/projectCenter/businessdata")
@Filters({ @By(type = GlobalsFilter.class) , @By(type = UserLoginFilter.class)})
public class ProjectDataManagerController {
	
	private static Log log = Logs.get(); 
	
	@Inject
	private ProjectDesignManagerServiceImpl projectDesignManagerServiceImpl;

	@Inject
	private DaoDcProjectDesignCell daoDcProjectDesignCell;

	@Inject
	private DaoPcProjectData daoPcProjectData;
	
	@Inject
	private DcCarmaintenanceFacilityDao dcCarmaintenanceFacilityDao;

	@Inject
	private DaoDcProjectMention daoDcProjectMention;
	
	@Inject
	private DaoPcProjectFile daoPcProjectFile;
	
	@Inject
	private PreviewFileServiceImpl previewFileServiceImpl;

	//查询项目列表
	@At("/projectList")
	@Ok("json:full")
	public QueryResult findProjectList(@Param("..") NutMap nutMap){
		return projectDesignManagerServiceImpl.findProjectList(nutMap);
	}

	@At("/updateProject") 
	@Ok("json")
	public AjaxResult updateProject(@Param("..") PcProjectInfo dcProjectInfo , HttpSession httpSession){
		return projectDesignManagerServiceImpl.updateProject(dcProjectInfo, httpSession);
	}
	
	@At("/delProjectById")
	@Ok("json")
	public AjaxResult delProjectById(@Param("id") String id){
		return projectDesignManagerServiceImpl.delProject(id);
	}
	
	//查找项目相关设计内容
	@At("/findDesignContentByProjectId")
	@Ok("json")
	public List<Map> findDesignContentByProjectId(@Param("..") NutMap nutMap){
		return projectDesignManagerServiceImpl.findDesignContentByProjectId(nutMap);
	}
	
	//项目树
	@At("/projectDesign/?")
	@Ok("beetl:/projectRoot/pcCenter/designTree/projectTree.html")
	public NutMap projectDesign(String project_id){
		NutMap nutMap = new NutMap();
		nutMap.put("poject_id", project_id);
		return nutMap;
	}
	
	//结构化数据表单页面跳转
	@At("/structuredDataManage/?/?")
	@Ok("beetl:/projectRoot/pcCenter/mentionData/structuredData.html")
	public NutMap structuredDataManage(String mention_id , String project_id){
		NutMap nutMap = new NutMap();
		nutMap.put("mention_id", mention_id);
		nutMap.put("project_id", project_id);
		//查询 结构化数据 表名
		DcProjectMentionInformation dcProjectMentionInformation = daoDcProjectMention.fetch(mention_id);
		String table_name = new StringBuffer("dc_mention_").append(dcProjectMentionInformation.getMention_information_code()).toString();
		nutMap.put("t_name", table_name);
		return nutMap;
	}

	//一键初始化 既有动车设施表
	@At("/initJydcss/?/?")
	@Ok("json")
	public AjaxResult initJydcss(String project_id,String table_name){
		PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
		return projectDesignManagerServiceImpl.initJydcssTable(project_id,table_name,project_info.getProject_design_content_name());
	}

	//一键初始化 既有机务设施表
	@At("/initJyjwss/?/?")
	@Ok("json")
	public AjaxResult initJyjwss(String project_id,String table_name){
		PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
		return projectDesignManagerServiceImpl.initJyjwssTable(project_id,table_name,project_info.getProject_design_content_name());
	}

	@At("/totalDesignDataManage")
	@Ok("beetl:/projectRoot/pcCenter/mentionData/structuredData.html")
	public NutMap totalDesignDataManage(@Param("table_name") String table_name , @Param("project_id") String project_id){
		DcProjectMentionInformation object = daoDcProjectMention.findObjByName(table_name);
		String mention_id = object!=null?object.getId():"";
		return new NutMap("t_name","dc_mention_"+table_name).addv("project_id", project_id).addv("mention_id", mention_id);
	}
	
	
	
	
	//非结构化数据表单维护
	@At("/notStructuredDataManage/?/?")
	@Ok("beetl:/projectRoot/pcCenter/mentionData/notStructuredData.html")
	public NutMap notStructuredDataManage(String mention_id , String project_id ,
			HttpServletRequest request , HttpServletResponse response){
		NutMap nutMap = new NutMap();
		nutMap.put("mention_id", mention_id);
		nutMap.put("project_id", project_id);
		return nutMap;
	}
	
	
	//结构化提入资料维护
	@At("/mentionDataManage")
	@Ok("json:full")
	public Object mentionDataManage(@Param("..") NutMap param , HttpServletRequest request){
		try {
			return projectDesignManagerServiceImpl.mentionDataManage(param,request);
		} catch (IOException e) {
			e.printStackTrace();
			return AjaxResult.error("系统异常,请重试!");
		}
	}
	
	//更新表单项
	@At("/updateMentionDataByTable/?")
	@Ok("json")
	public AjaxResult updateMentionDataByTable(String mention_data_id , @Param("..") NutMap nutMap){
		return projectDesignManagerServiceImpl.updateMentionDataByTable(mention_data_id, nutMap);
	}
	
	//更新设备概算表
	@At("/updateDesignBudgetByTableName/?")
	@Ok("json")
	public AjaxResult updateDesignBudgetByTableName(String table_name , @Param("..") NutMap nutMap){
		return projectDesignManagerServiceImpl.updateEquipmentBudgetDataByTableName(table_name,nutMap);
	}
	
	//删除表单项
	@At("/delMentionDataById/?/?")
	@Ok("json")
	public AjaxResult delMentionDataById(String mention_data_id , String id){
		return projectDesignManagerServiceImpl.delMentionDataById(mention_data_id, id);
	}
	
	//删除设备概算
	@At("/delEquipmentBudgetDataById/?/?")
	@Ok("json")
	public AjaxResult delEquipmentBudgetDataById(String table_name , String id){
		return projectDesignManagerServiceImpl.delEquipmentBudgetDataById(table_name, id);
	}
	
	
	//设备配备维护
	@At("/equipmentEquip/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/projectEquipmentEquip.html")
	public NutMap equipmentEquip(String project_id){
		NutMap nutMap = new NutMap("project_id",project_id);
		return nutMap;
	}
	
	//设备自检
	@At("/equipmentSelfInspection/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentSelfInspection.html")
	public NutMap equipmentSelfInspection(String project_id){
		return new NutMap("project_id",project_id);
	}
	
	//设备设计
	@At("/equipmentDesign/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/tab.html")
	public NutMap equipmentDesign(String project_id){
		return new NutMap("project_id",project_id);
	}

	//设备配备初始化
	@At("/initEquipmentInfo/?")
	@Ok("json:full")
	public AjaxResult initEquipmentInfo(String project_id) {
		Map<String, Object> param = new HashMap<>();
		param.put("project_id",project_id);
		PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
		if (project_info.getProject_design_content_name().equals("动车运用所")){
			//检查库线数  根据 设计动车设施表 来
			//设计动车设施
			param.put("sjdcss_name",projectDesignManagerServiceImpl.getSjdcssTableName(project_info.getProject_design_phase_id(),project_info.getProject_design_content_id()));
			KnowledgeSession knowledgeSession = RuleTool.getSessionFactory("设备配备计算规则/sbxxjs");
			knowledgeSession.fireRules(param);
		} else if (project_info.getProject_design_content_name().equals("物资总库")) {
			//物资总库设备选型 依赖于 提入资料 项目主要技术标准表
			List<DcProjectMentionInformation> dcProjectMentionInformations = daoDcProjectMention.query(Cnd.where("mention_information_name","like","%项目专用信息%").and("del_flag","=","0"));
			if (null!=dcProjectMentionInformations && dcProjectMentionInformations.size()>0) {
				param.put("xmzyjsbz_name","dc_mention_"+dcProjectMentionInformations.get(0).getMention_information_code());
			}
			KnowledgeSession knowledgeSession = RuleTool.getSessionFactory("物资总库计算/cal_wzzksbxx");
			knowledgeSession.fireRules(param);
		}

		return null;
	}


	//设备自检初始化
	@At("/initEquipmentSelfCheck/?")
	@Ok("json:full")
	public void initEquipmentSelfCheck(String project_id) {
		Map<String, Object> param = new HashMap<>();
		param.put("project_id",project_id);
		PcProjectInfo project_info = daoPcProjectData.fetch(project_id);
		/*//设备配备计算，需要知道 枢纽工作量详情表 表名 数据来源
		List<DcProjectDesignCell> designCells = daoDcProjectDesignCell.query(Cnd.where("design_cell_table_name","like","枢纽工作量详情%").and("project_design_phase_id","=",project_info.getProject_design_phase_id()).and("project_design_content_id","=",project_info.getProject_design_content_id()));
		if (null!=designCells && designCells.size()>0) {
			param.put("lcdsb_name","dc_designcell_"+designCells.get(0).getDesign_cell_table_code());
		}*/

		//检查库线数  根据 设计动车设施表 来
		//设计动车设施
		param.put("sjdcss_name",projectDesignManagerServiceImpl.getSjdcssTableName(project_info.getProject_design_phase_id(),project_info.getProject_design_content_id()));

		KnowledgeSession knowledgeSession = RuleTool.getSessionFactory("设备配备计算规则/sbzjjs");
		knowledgeSession.fireRules(param);
	}



	//设备选型
	@At("/equipmentSelection/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/projectEquipmentSelection.html")
	public NutMap equipmentSelection(String equipment_equip_id , String tab_type){
		NutMap nutMap = new NutMap("equip_id",equipment_equip_id).addv("tab_type", tab_type);
		return nutMap;
	}
	
	//根据项目id初始化该项目所拥有的所有设计配备表
	@At("/initEquipmentEquipListByProjectId")
	@Ok("json:full")
	public Object findEquipmentEquipListByProjectId(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.findEquipmentEquipListByProjectId(param);
	}
	
	//根据设备配备表id查询子设备表
	@At("/findListByEquipmentEquipId")
	@Ok("json:full")
	public Object findListByEquipmentEquipId(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.findListByEquipmentEquipId(param);
	}
	
	//更新设备配备表
	@At("/updateEquipmentEquip")
	@Ok("json:full")
	public Object updateEquipmentEquip(@Param("..") PcProjectEquipmentEquip pcProjectEquipmentEquip){
		return projectDesignManagerServiceImpl.updateEquipmentEquip(pcProjectEquipmentEquip);
	}
	
	@At("/updateEquipmentEquipInfo")
	@Ok("json")
	public Object updateEquipmentEquipInfo(@Param("..") PcProjectEquipmentEquipInfo pcProjectEquipmentEquipInfo){
		return projectDesignManagerServiceImpl.updateEquipmentEquipInfo(pcProjectEquipmentEquipInfo);
	}
	
	@At("/delEquipmentEquipById")
	@Ok("json")
	public Object delEquipmentEquipById(@Param("id") String id){
		return projectDesignManagerServiceImpl.delObject(PcProjectEquipmentEquip.class, id);
	}
	
	@At("/delEquipmentEquipInfoById")
	@Ok("json")
	public Object delEquipmentEquipInfoById(@Param("id") String id){
		return projectDesignManagerServiceImpl.delObject(PcProjectEquipmentEquipInfo.class, id);
	}
	
	@At("/equipmentSelection")
	@Ok("json")
	public Object equipmentSelection(@Param("..") PcProjectEquipmentEquipInfo object){
		return projectDesignManagerServiceImpl.equipmentSelection(object);
	}
	
	//设备一键选型
	@At("/allEquipmentEquip")
	@Ok("json")
	public AjaxResult allEquipmentEquip(@Param("equip_id") String equip_id){
		try {
			return projectDesignManagerServiceImpl.allEquipmentEquip(equip_id);
		} catch (Exception e) {
			e.printStackTrace();
			return AjaxResult.error("系统异常!");
		}
	}
	
	//单体图设计
	@At("/singleDrawDesign/?")
	@Ok("beetl:/projectRoot/pcCenter/drawDesign/singleDraw/singleDrawDesign.html")
	public Object singleDrawDesign(String project_id){
		return new NutMap("project_id",project_id);
	}
	
	//总图设计
	@At("/totalDrawDesign/?")
	@Ok("beetl:/projectRoot/pcCenter/drawDesign/totalDraw/tab.html")
	public Object totalDrawDesign(String project_id){
		return new NutMap("project_id",project_id);
	}
	
	//设备概算计算
	@At("/equipmentBudget/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentBudget.html")
	public Object equipmentBudget(String project_id){
		return new NutMap("project_id",project_id);
	}
	
	//设备基础资料
	@At("/equipmentBasics/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentBasics.html")
	public Object equipmentInfo(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		nutMap.addv("result_data", dcManufacturerEquipmentField);
		return nutMap;
	}
	
	//厂商信息
	@At("/equipmentCsxx/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentCsxx.html")
	public Object equipmentCsxx(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		nutMap.addv("result_data", dcManufacturerEquipmentField);
		return nutMap;
	}
	
	//设备照片
	@At("/equipmentPhoto/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentPhoto.html")
	public Object equipmentPhoto(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		if(dcManufacturerEquipmentField != null){
			String photo_ids = dcManufacturerEquipmentField.getEquipment_photo();
			if(StringUtils.isNotBlank(photo_ids)){
				String [] photo_arr = photo_ids.split(",");
				nutMap.addv("result_data",previewFileServiceImpl.getUrls(photo_arr));
			}
		}
		return nutMap;
	}
	
	//用户需求说明书
	@At("/equipmentDemandBook/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentDemandBook.html")
	public Object equipmentDemandBook(String manufacturer_id ,String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		if(dcManufacturerEquipmentField != null){
			String demand_book_id = dcManufacturerEquipmentField.getEquipment_yhxqs();
			if(StringUtils.isNotBlank(demand_book_id)){
				String [] demand_book_arr = demand_book_id.split(",");
				nutMap.addv("result_data",previewFileServiceImpl.getUrlByFiles(demand_book_arr));
			}
		}
		return nutMap;
	}
	
	//设备技术接口
	@At("/equipmentJsjk/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentJsjk.html")
	public Object equipmentJsjk(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		if(dcManufacturerEquipmentField != null){
			String jsjk_ids = dcManufacturerEquipmentField.getEquipment_jsjk();
			if(StringUtils.isNotBlank(jsjk_ids)){
				String [] jsjk_id_arr = jsjk_ids.split(",");
				nutMap.addv("result_data",previewFileServiceImpl.getUrlByFiles(jsjk_id_arr));
			}
		}
		return nutMap;
	}
	
	//土建条件图
	@At("/equipmentTjtjt/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentTjtjt.html")
	public Object equipmentTjtjt(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		if(dcManufacturerEquipmentField != null){
			String tjtjt_ids = dcManufacturerEquipmentField.getEquipment_tjtjt();
			if(StringUtils.isNotBlank(tjtjt_ids)){
				String [] tjtjt_id_arr = tjtjt_ids.split(",");
				nutMap.addv("result_data",previewFileServiceImpl.getUrlByFiles(tjtjt_id_arr));
			}
		}
		return nutMap;
	}
	
	//设备bim模型
	@At("/equipmentBimModel/?/?/?")
	@Ok("beetl:/projectRoot/pcCenter/equipmentDesign/equipmentBimModel.html")
	public Object equipmentBimModel(String manufacturer_id , String equipment_id , String equip_id){
		NutMap nutMap = new NutMap("manufacturer_id", manufacturer_id).addv("equipment_id", equipment_id).addv("equip_id", equip_id);
		DcManufacturerEquipmentField dcManufacturerEquipmentField = projectDesignManagerServiceImpl.getDaoDcProjectEquipmentField().findObjByEquipmentAndManfacturer(manufacturer_id,equipment_id);
		if(dcManufacturerEquipmentField != null){
			String bim_ids = dcManufacturerEquipmentField.getEquipment_bim_model();
			if(StringUtils.isNotBlank(bim_ids)){
				String [] bim_id_arr = bim_ids.split(",");
				nutMap.addv("result_data",previewFileServiceImpl.getUrlByFiles(bim_id_arr));
			}
		}
		return nutMap;
	}
	
	//查询设备集
	@At("/findEquipmentByTypeId")
	@Ok("json:full")
	public Object findEquipmentByTypeId(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.getDaoDcEquipment().findPagePcEquipmentListByEquipmentTypeId(param);
	}
	
	//查询设备自检结果
	@At("/initEquipmentSelfCheckResult")
	@Ok("json:full")
	public Object initEquipmentSelfCheckResult(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.getDaoPcEquipmentSelfCheckResult().findResultByProjectId(param);
	}
	
	//查询工艺设备集
	@At("/findGyEquipmentList")
	@Ok("json:full")
	public Object findGyEquipmentList(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.getDaoDcManufacturerEquipment().findGyEquipmentList(param);
	}
	
	//查询工艺设备类型
	@At("/findEquipmentTypeList")
	@Ok("json:full")
	public Object findEquipmentTypeList(){
		return projectDesignManagerServiceImpl.getDaoDcManufacturerEquipment().findEquipmentTypeList();
	}

	//查询动车设施库
	@At("/findBulletFacilityList")
	@Ok("json:full")
	public Object findBulletFacilityList(@Param("..") NutMap param){
		return projectDesignManagerServiceImpl.getDaoDcManufacturerEquipment().findBulletFacilityList(param);
	}
	//查询机务设施数据库
	@At("/findCarmaintenanceFacility")
	@Ok("json:full")
	public QueryResult findCarmaintenanceFacility(@Param("..") NutMap param){
		return dcCarmaintenanceFacilityDao.findCarmaintenanceFacility(param);
	}
	
	//打开动车设施库在地图上的标记
	@At("/showMapForBulletFacility")
	@Ok("beetl:/projectRoot/dcCenter/historyDataBase/webgis.html")
	public NutMap showMapForBulletFacility(@Param("x_coord") String x_coord , @Param("y_coord") String y_coord){
		return new NutMap("x_coord",x_coord).addv("y_coord", y_coord);
	}
	
	//更新机务设施数据库
	@At("/updateFacility")
	@Ok("json:full")
	public AjaxResult updateFacility(@Param("..") DcCarmaintenanceFacility dcCarmaintenanceFacility){
		return dcCarmaintenanceFacilityDao.updateFacility(dcCarmaintenanceFacility);
	}
	
	@At("/updateFacilityInfo")
	@Ok("json:full")
	public AjaxResult updateFacilityInfo(@Param("..") NutMap param){
		return dcCarmaintenanceFacilityDao.updateFacilityInfo(param);
	}
	
	
	@At("/delFacility/?")
	@Ok("json:full")
	public AjaxResult delFacility(String id){
		return dcCarmaintenanceFacilityDao.delete(id)==1?AjaxResult.success("删除成功!"):AjaxResult.error("删除失败!");
	}
	
}
